package com.hnust.utils;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;

/**
 * 创建人：zhangRuWang
 * 创建时间：2022/4/21
 * 描述：
 */
@Data
public class Message<T> implements Serializable {
    private Integer messageCode;
    private String messageType;
    private T messageContent;

    public static <T> String getAllSensor(T t){
        Message<T> message=new Message<T>();
        message.messageCode=21;
        message.messageType="getAllSensor";
        message.messageContent=t;
        return JSON.toJSONString(message);
    }

    public static <T> String getAllDevice(T t){
        Message<T> message=new Message<T>();
        message.messageCode=11;
        message.messageType="getAllDevice";
        message.messageContent=t;
        return JSON.toJSONString(message);
    }

    public static <T> String getSensorState(T t){
        Message<T> message=new Message<T>();
        message.messageCode=22;
        message.messageType="getSensorState";
        message.messageContent=t;
        return JSON.toJSONString(message);
    }

    public static <T> String getDeviceState(T t){
        Message<T> message=new Message<T>();
        message.messageCode=12;
        message.messageType="getDeviceState";
        message.messageContent=t;
        return JSON.toJSONString(message);
    }

    public static <T> String getNetWorkState(T t){
        Message<T> message=new Message<T>();
        message.messageCode=32;
        message.messageType="getNetWorkState";
        message.messageContent=t;
        return JSON.toJSONString(message);
    }

}
